package com.part2.business.function.Impl;

import java.util.List;

import com.part2.action.common.validator.Validator;
import com.part2.beans.Products;
import com.part2.business.function.ProductsService;
import com.part2.common.query.Page;
import com.part2.dao.common.BaseDao;
import com.part2.dao.function.ProductsDao;

public class ProductsServiceImpl implements com.part2.business.function.ProductsService {

	private BaseDao<Products, String> baseDao;
	private ProductsDao productsDao;

	public void setBaseDao(BaseDao<Products, String> baseDao) {
		this.baseDao = baseDao;
	}

	public void setProductsDao(ProductsDao productsDao) {
		this.productsDao = productsDao;
	}

	public void addProducts(Products Products) {
		// TODO Auto-generated method stub
		baseDao.save(Products);
	}

	public void deleteProducts(String id) {
		// TODO Auto-generated method stub
		if (Validator.isNotNull(id)) {
			Products pro = this.findProductsByPrimeKey(id);
			if (pro != null)
				baseDao.delete(pro);
		}
	}

	public List<Products> findProducts() {
		// TODO Auto-generated method stub
		return baseDao.findAll(Products.class);
	}

	public Page<Products> findProducts(Page<Products> page,String bId) {
		// TODO Auto-generated method stub
		return productsDao.findProducts(page,bId);
	}

	public Products findProductsByPrimeKey(String id) {
		// TODO Auto-generated method stub
		return productsDao.findProductsByPrimeKey(id);
	}

	public void updateProducts(Products Products) {
		// TODO Auto-generated method stub
		baseDao.saveOrUpdate(Products);
	}

	public List<Products> findProductsByBigClass(String id) {
		// TODO Auto-generated method stub
		return productsDao.findProductsByBigClass(id);
	}

	public Page<Products> findProductsBySearch(Page<Products> page, String key) {
		// TODO Auto-generated method stub
		return productsDao.findProductsBySearch(page, key);
	}

}
